package com.jiudengnile.dr.biz.dao.ibatis;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.jiudengnile.dr.biz.dao.RecordDataDAO;
import com.jiudengnile.dr.biz.domains.RecordDataDO;

public class RecordDataDAOIbatis extends SqlMapClientDaoSupport implements RecordDataDAO {

	public long create(RecordDataDO recordData) {
		return (Long)this.getSqlMapClientTemplate().insert("RecordDataDAO.create", recordData);
	}

	public void delete(long id) {
		this.getSqlMapClientTemplate().update("RecordDataDAO.delete", id);
	}

	public void update(RecordDataDO recordData) {
		this.getSqlMapClientTemplate().update("RecordDataDAO.update", recordData);
	}

	public RecordDataDO queryById(long id) {
		return (RecordDataDO)this.getSqlMapClientTemplate().queryForObject("RecordDataDAO.queryById", id);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<RecordDataDO> queryLocations(String uid, Date start, Date end) {
		Map<String, Object> param = new HashMap<String, Object>(4);
		param.put("uid", uid);
		param.put("start", start);
		param.put("end", end);
		return (List<RecordDataDO>)this.getSqlMapClientTemplate().queryForList("RecordDataDAO.queryLocations", param);
	}
	
}
